package com.example.service;

import com.example.entity.BaseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author chentao
 * @create 2023/3/11 19:43
 * @since 1.0.0
 */
@Service
public class ObjectHandlerServiceImpl<T extends BaseEntity> implements ObjectHandlerService<T> {

    @Resource
    private List<ObjectHandler<T>> handlerList = new ArrayList<>();

    @Override
    public void handlerAdd(T entity) {
        for (ObjectHandler objectHandler : handlerList) {
            objectHandler.handlerAdd(entity);
        }
    }

    @Override
    public void handlerDelete(T entity) {
        for (ObjectHandler objectHandler : handlerList) {
            objectHandler.handlerDelete(entity);
        }
    }
}